package ThreadDemo;

import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

/*
 * Author: JacksonCoder
 * FileName: MyCallable
 * Version: 1.0.0
 */
public class MyCallable implements Callable<String> {

    public static void main(String[] args) {
        MyCallable myCallable = new MyCallable();
        FutureTask<String> futureTask = new FutureTask<>(myCallable);
        Thread thread = new Thread(futureTask);
        thread.start();

        try{
            System.out.println("Result: " + futureTask.get());
        } catch(Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public String call() throws Exception {
        return "Callable result";
    }
}
